package com.zhaodui.jdwx;

import com.wxapi.WxApiCall.WxApiCall;
import com.wxapi.model.RequestModel;
import com.xiaoleilu.hutool.http.HttpUtil;
import com.zhaodui.alibaba.HttpUtils;
import com.zhaodui.conf.entity.WxConfigEntity;
import com.zhaodui.restapi.entity.fxjClwz;
import com.zhaodui.tongdun.BodyGuardApiInvoker;
import com.zhaodui.tongdun.BodyGuardApiResponse;
import com.zhaodui.util.UploadController;
import com.zhaodui.util.Base64Utils;
import com.zhaodui.util.HttpRequest;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.apache.velocity.runtime.directive.Foreach;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.*;
import org.jeecgframework.web.system.pojo.base.TSUser;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Validator;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.util.*;

import static com.baidu.inf.iis.bcs.utils.ServiceUtils.toHex;


public class jdwxController {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(jdwxController.class);


	@Autowired
	private SystemService systemService;
	@Autowired
	private Validator validator;
	

	private static String sfzappkey = ResourceUtil.getConfigByName("sfzappkey");// = "f9e428a8faddcf9a014556f533339824";//身份证KEY  b16de0f270bb475cd0829aa9b1a715ff  f9e428a8faddcf9a014556f533339824
	private static String rldbappkey = ResourceUtil.getConfigByName("rldbappkey");//"6e2e4176995007b00b0a83c840366cb9";//人脸对比KEY
	private static String clpgappkey = ResourceUtil.getConfigByName("clpgappkey");// "5cc44b43961134b5417a695b0a301ac2";//车辆识别KEY
	private static String zjsbappkey = ResourceUtil.getConfigByName("zjsbappkey");//"ebae07292b2cbb19deb121bae91f90ce";//证件识别KEY
	private static String jdwxkey = ResourceUtil.getConfigByName("jdwxkey");//"6e45ee9333c5e3ffae0bdf0fb34a68f0";//京东万象KEY


	/**
		 * 身份证实名认证
		 * imgfile 文件路径
		 * @return
		 * @throws Exception 
		 */

		private String getfxbbres(String keyall){
			String result = "";
			try{
//				FxjFxbbResEntity fxbbres = systemService.findByProperty(FxjFxbbResEntity.class,"keyall",keyall).get(0);
//				if(fxbbres!=null){
//					result = fxbbres.getFxresult();
//				}
			}catch (Exception e){

			}

			return result;
		}
	private void setfxbbres(String keyall,String result){
			try{
//				FxjFxbbResEntity fxbbres = new FxjFxbbResEntity();
//				fxbbres.setKeyall(keyall);
//				fxbbres.setFxresult(result);
//				systemService.save(fxbbres);
			}catch (Exception e){

			}

	}

	@ResponseBody
	@RequestMapping(params = "dotongdun")
	public String dotongdun(String account_name,String id_number,String account_mobile, String home_address, String card_number,   HttpServletRequest request) throws Exception {
//		getkey();
		systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);


		WxConfigEntity wxConfigEntity = systemService.findUniqueByProperty(WxConfigEntity.class,"appCode","tongdun");
		 String apiUrl = wxConfigEntity.getNotifyUrl() ;  //"https://apitest.tongdun.cn/bodyguard/apply/v4.3";
     String PARTNER_CODE = wxConfigEntity.getAppId() ;  // "dscd";// 合作方标识
    String PARTNER_KEY  =  wxConfigEntity.getAppSecret() ;  //"0b89e46b04d3421b9d4a7da1a6e08fd6";//合作方密钥
     String PARTNER_APP  =  wxConfigEntity.getAppKey() ;  //"dscd_app";//应用名

		String keyall = "dotongdun" +id_number;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		}
		Map<String, Object> params = new HashMap<String, Object>();
//        params.put("lend_company", "test");
//        params.put("coborrower_home_address", "浙江省杭州市西湖区古荡新村2幢201");
//        params.put("company_type", "私营");
//        params.put("career", "半专业人员");
//        params.put("contact3_relation", "test");
//        params.put("occupation", "见习专员");
//        params.put("customer_channel", "test");
//        params.put("contact5_name", "test");
//        params.put("work_phone", "0571-111111111");
//        params.put("surety_name", "刘能");
//        params.put("contact1_id_number", "test");
//        params.put("contact5_id_number", "test");
//        params.put("coborrower_id_number", "321282555555555555");
//        params.put("loan_purpose", "车贷");
//        params.put("company_address", "test");
//        params.put("coborrower_phone", "0571-10101010");
//        params.put("surety_phone", "0571-222222222");
//        params.put("token_id", "test");
//        params.put("house_property", "有房");
//        params.put("contact2_id_number", "test");
//        params.put("diploma", "研究生");
//        params.put("annual_income", "100000-200000");
		if(StringUtil.isNotEmpty(id_number)){
			params.put("id_number", id_number);
		}
        params.put("biz_code", "antifraud");
//        params.put("surety_id_number", "321282333333333333");
//        params.put("device_id", "test");
		if(StringUtil.isNotEmpty(card_number)){
			params.put("card_number", card_number);
		}
//        params.put("coborrower_company", "浙江理工大学");
//        params.put("contact1_mobile", "test");
//        params.put("account_phone", "0571-42331233");
//        params.put("loan_amount", "10000");
//        params.put("qq_number", "313131313");
//        params.put("monthly_income", "12000以上");
//        params.put("apply_province", "四川");
//        params.put("surety_mobile", "15223456789");
//        params.put("contact4_relation", "test");
//        params.put("contact5_mobile", "test");
//        params.put("loan_term", "12");
		if(StringUtil.isNotEmpty(account_mobile)){
			params.put("account_mobile", account_mobile);

		}
//        params.put("mobile_name_consistence", "3");
//        params.put("contact3_mobile", "test");
//        params.put("organization_address", "浙江省杭州市阿里巴巴西溪园区");
//        params.put("work_time", "1年以下");
//        params.put("contact3_id_number", "test");
//        params.put("contact3_name", "test");
//        params.put("coborrower_name", "王五");
//        params.put("loan_date", "2015-11-19");
//        params.put("account_phone_work", "test");
//        params.put("coborrower_relation", "test");
//        params.put("registered_address", "浙江省杭州市西湖区古荡新村2幢101");
//        params.put("applyer_type", "在职");
//        params.put("is_cross_loan", "否");
//        params.put("industry", "金融业");
//        params.put("surety_company_address", "浙江省杭州市下城区潮王路18号");
//        params.put("contact2_name", "test");
//        params.put("resp_detail_type", "test");
//        params.put("surety_home_address", "浙江省杭州市西湖区古荡新村");
//        params.put("account_email", "212121212@qq.com");
//        params.put("account_address_work", "test");
		if(StringUtil.isNotEmpty(home_address)){
			params.put("home_address", home_address);

		}
//        params.put("marriage", "未婚");
		if(StringUtil.isNotEmpty(account_name)){
			params.put("account_name", account_name);

		}
//        params.put("contact5_relation", "test");
//        params.put("house_type", "商品房");
//        params.put("contact_address", "浙江省杭州市西湖区古荡新村2幢101");
//        params.put("black_box", "test");
//        params.put("contact4_id_number", "test");
//        params.put("contact1_name", "test");
//        params.put("contact2_relation", "test");
//        params.put("coborrower_mobile", "17012345678");
//        params.put("apply_channel", "app申请");
//        params.put("contact4_name", "test");
//        params.put("ip_address", "test");
//        params.put("loan_term_unit", "test");
//        params.put("coborrower_company_address", "杭州市江干区2号大街928号");
//        params.put("contact1_relation", "test");
//        params.put("contact4_mobile", "test");
//        params.put("event_occur_time", "2016-03-01 08:16:30");
//        params.put("organization", "阿里巴巴西溪园区");
//        params.put("contact2_mobile", "test");
		BodyGuardApiResponse bodyGuardApiResponse = new BodyGuardApiInvoker().invoke( apiUrl,  PARTNER_CODE,  PARTNER_KEY,  PARTNER_APP,params);
		result = 		bodyGuardApiResponse.getResult_desc();

		;
		setfxbbres(keyall,result);
		return result;

	}


	@ResponseBody
		@RequestMapping(params = "dosmrz")
		public String dosmrz(String cardNo,String realName, HttpServletRequest request) throws Exception {

                String keyall = "dosmrz" +cardNo;
			    String result =getfxbbres(keyall);
			    if(!StringUtil.isEmpty(result)){
			    	return  result;
				}
				String url ="https://way.jd.com/youhuoBeijing/test";//请求接口地址
	 
				RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("cardNo",cardNo);
				queryMap.put("realName",realName);//固定值：
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
			    setfxbbres(keyall,result);
				System.out.print(result);

			return result;
		
		}






		/**
		 * 身份证识别
		 * imgfile 文件路径
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dosfzsb")
		public String dosfzsb(String imgfile,String shibietype, HttpServletRequest request)   {
			String message = null;
			String keyall = "dosfzsb" +imgfile;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
			System.out.print("imgfile*************"+imgfile);
			AjaxJson j = new AjaxJson();
	        String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
			String imgpath=ctxPath+File.separator+imgfile;
			System.out.print("imgpath*************"+imgpath);

				String url ="https://way.jd.com/wintone/IDCard_base64";//请求接口地址
				RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
//			    model.setFilePath(imgfile);
				model.setBodyStr("img="+ Base64Utils.GetImageStr(imgfile));	//body参数
				System.out.print("getBodyStr*************"+imgfile);

				Map queryMap = new HashMap();
				queryMap.put("typeId",shibietype);
				//证件类型：1（一代身份证 ）2（身份证正面）3（身份证背面）4（临时身份证) 1001（香港永久性居民身份证）1005（澳门身份证）1031（台湾身份证正面）1032（台湾身份证背面 ）
				model.setQueryParams(queryMap);
			    System.out.print("result**123456");

			    WxApiCall call = new WxApiCall();
			     System.out.print("callt**789000"+call.toString());
				call.setModel(model);
				result = call.request();
				System.out.print("result**?????"+result);
			setfxbbres(keyall,result);

			return result;
		}
		/**
		 * 证件识别
		 * imgfile 文件路径
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dozjsb")
		public String dozjsb(String imgfile,String shibietype, HttpServletRequest request)   {
			String message = null;
			String keyall = "dozjsb" +imgfile;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
			AjaxJson j = new AjaxJson();
	        String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
			String imgpath=ctxPath+File.separator+imgfile;
			File fileDelete = new File(imgpath);

				String url ="https://way.jd.com/wintone/Card_base64";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				model.setBodyStr("img="+ Base64Utils.GetImageStr(imgfile));	//body参数
				System.out.print(model.getBodyStr());

				Map queryMap = new HashMap();
				queryMap.put("typeId",shibietype);
				//证件类型: 5(驾照)6(行驶证)7(军官证)9(中华人民共和国往来港澳通行证)10(台湾居民往来大陆通行证)11(大陆居民往来台湾通行证 )12(签证)13(护照)14(港澳居民来往内地通行证正面)15(港澳居民来往内地通行证背面)16(户口本)1000(居住证)1003(边民证照片页)1004(边民证个人信息页)1030(全民健康保险卡)			model.setQueryParams(queryMap);
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}

	/**
	 * 证件识别
	 * imgfile 文件路径
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "doyyzzsb")
	public String doyyzzsb(String imgfile,String shibietype, HttpServletRequest request)   {
		String message = null;
		String keyall = "dozjsb" +imgfile;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		}
		AjaxJson j = new AjaxJson();
		String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
		systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);

		WxConfigEntity wxConfigEntity = systemService.findUniqueByProperty(WxConfigEntity.class,"appCode","alyyzzsb");
		String host = "https://dm-58.data.aliyun.com";
		String path = "/rest/160601/ocr/ocr_business_license.json";
		String method = "POST";
		String appcode = wxConfigEntity.getAppId();
		Map<String, String> headers = new HashMap<String, String>();
		//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
		headers.put("Authorization", "APPCODE " + appcode);
		//根据API的要求，定义相对应的Content-Type
		headers.put("Content-Type", "application/json; charset=UTF-8");
		Map<String, String> querys = new HashMap<String, String>();
		String bodys = "{\"image\":\""+Base64Utils.GetImageStr(imgfile)+"\"}";
		try {
			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
			System.out.println(response.toString());
			//获取response的body
			result = EntityUtils.toString(response.getEntity());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.print(result);
		setfxbbres(keyall,result);
		return result;
	}
	/**
	 * 证件识别
	 * imgfile 文件路径
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "dozzsfpsb")
	public String dozzsfpsb(String imgfile,String shibietype, HttpServletRequest request)   {
		String message = null;
		String keyall = "dozjsb" +imgfile;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		}
		AjaxJson j = new AjaxJson();
		String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
		systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);

		WxConfigEntity wxConfigEntity = systemService.findUniqueByProperty(WxConfigEntity.class,"appCode","alzzsfpsb");
		String host = "https://ocrapi-invoice.taobao.com";
		String path = "/ocrservice/invoice";
		String method = "POST";
		String appcode = wxConfigEntity.getAppId();
		Map<String, String> headers = new HashMap<String, String>();
		//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
		headers.put("Authorization", "APPCODE " + appcode);
		//根据API的要求，定义相对应的Content-Type
		headers.put("Content-Type", "application/json; charset=UTF-8");
		Map<String, String> querys = new HashMap<String, String>();
		String bodys = "{\"img\":\""+Base64Utils.GetImageStr(imgfile)+"\"}";
		try {
			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
			System.out.println(response.toString());
			//获取response的body
			result = EntityUtils.toString(response.getEntity());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.print(result);
		setfxbbres(keyall,result);
		return result;
	}


	/**
	 * 证件识别
	 * imgfile 文件路径
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "doalbdcsb")
	public String doalbdcsb(String imgfile,String shibietype, HttpServletRequest request)   {
		String message = null;
		String keyall = "dozjsb" +imgfile;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		}
		AjaxJson j = new AjaxJson();
		String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
		systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);

		WxConfigEntity wxConfigEntity = systemService.findUniqueByProperty(WxConfigEntity.class,"appCode","albdcsb");
		String host = "https://ocrapi-estate-cert.taobao.com";
		String path = "/ocrservice/estateCert";
		String method = "POST";
		String appcode = wxConfigEntity.getAppId();
		Map<String, String> headers = new HashMap<String, String>();
		//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
		headers.put("Authorization", "APPCODE " + appcode);
		//根据API的要求，定义相对应的Content-Type
		headers.put("Content-Type", "application/json; charset=UTF-8");
		Map<String, String> querys = new HashMap<String, String>();
		String bodys = "{\"img\":\""+Base64Utils.GetImageStr(imgfile)+"\"}";
		try {
			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
			System.out.println(response.toString());
			//获取response的body
			result = EntityUtils.toString(response.getEntity());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.print(result);
		setfxbbres(keyall,result);
		return result;
	}
	/**
		 * 人脸对比
		 * imgfile 文件路径
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dorldb")
		public String dorldb(String cardNo,String realName,String imgfile, HttpServletRequest request)  {
			String message = null;
			String keyall = "dorldb" +realName+imgfile;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
			AjaxJson j = new AjaxJson();
	        String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
			String imgpath=ctxPath+File.separator+imgfile;
			File fileDelete = new File(imgpath);

				String url ="https://way.jd.com/VerifyIdcard/idfaceIdentity";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				model.setBodyStr("base64Str="+ Base64Utils.GetImageStr(imgfile));	//body参数
				System.out.print(model.getBodyStr());
				Map queryMap = new HashMap();
				queryMap.put("number",cardNo); //访问参数
				queryMap.put("name",realName); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}


		/**
		 * 个人涉诉查询
		 * 
		 * @return
		 * @throws Exception 
		 */
		//类别英文代码，执行公告-zxgg；失信公告-sxgg；裁判文书-cpws；法院公告-fygg；全类包含上述所有-all
		@ResponseBody
		@RequestMapping(params = "dogrss")
		public String dogrss(String cardNo,String realName,String sstype, HttpServletRequest request)   {
			String keyall = "dogrss" +realName+cardNo;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
//
//			String url ="https://way.jd.com/hxdcdk/gerensusong";//请求接口地址
			String url ="https://way.jd.com/freedt/personal";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("name",realName); //访问参数
				queryMap.put("idCard",cardNo); //访 问参数
//			queryMap.put("idcardNo",cardNo); //访问参数//
				queryMap.put("dataType","all"); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}

		/**
		 * 失信被执行人黑名单
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dogrsxhmd")
		public String dogrsxhmd(String cardNo,String realName, HttpServletRequest request)   {

			String keyall = "dogrsxhmd" +realName+cardNo;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
				String url ="https://way.jd.com/jisuapi/creditblacklist";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("realname",realName); //访问参数
				queryMap.put("idcard",cardNo); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		
		/**
		 * 		个人黑名单多头借贷综合查询 
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dogrhmd")
		public String dogrhmd(String cardNo,String realName,String mobile,String bankCardNo, HttpServletRequest request)  {
			String keyall = "dogrhmd" +realName+cardNo;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
	
				String url ="https://way.jd.com/XinShu/compBQuery";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("name",realName); //访问参数
				queryMap.put("idCard",cardNo); //访问参数
				queryMap.put("mobile",mobile); //访问参数
				if(!StringUtil.isEmpty(bankCardNo)){
					queryMap.put("bankCardNo",bankCardNo); //访问参数
				}
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		

		/**
		 * 		p2p
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dop2p")
		public String dop2p(String qq,String email,String mobile, HttpServletRequest request)   {
			String keyall = "dop2p" +qq+email;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
	
				String url ="https://way.jd.com/huiyutech/p2p_user";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("query_mobile",mobile); //必输
				queryMap.put("query_qq",qq); //访问参数
				queryMap.put("query_email",email); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		/**
		 * 		网络借贷黑名单
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dop2pblack")
		public String dop2pblack(String idcard,String name,String mobile, HttpServletRequest request)   {
			String keyall = "dop2pblack" +idcard+name;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
				String url ="https://way.jd.com/huiyutech/p2pBlackList";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("idcard",idcard); //访问参数
				queryMap.put("mobile",mobile); //访问参数
				queryMap.put("name",name); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		/**
		 * 		手机号码在网时长查询
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dozwsc")
		public String dozwsc(String mobile, HttpServletRequest request)   {
			String keyall = "dozwsc" +mobile;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
	
				String url ="https://way.jd.com/freedt/onlinetime";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("mobile",mobile); //必输
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		/**
		 * 		企业失信查询
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "doqysx")
		public String doqysx(String keyword, HttpServletRequest request)   {
			String keyall = "doqysx" +keyword;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			}
	
				String url ="https://way.jd.com/freedt/getExecutionListByName";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("keyword",keyword); //访问参数
				queryMap.put("skip","0"); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		
		/**
		 * 		个人失信查询
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dogrsx")
		public String dogrsx(String keyword, String number,HttpServletRequest request)   {
			String keyall = "dogrsx" +keyword;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			};
	
				String url ="https://way.jd.com/freedt/getExecutionListByNameOrCId";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("keyword",keyword); //访问参数
				queryMap.put("number",number); //访问参数
				queryMap.put("skip","0"); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		/**
		 * 		反欺诈识别 被检测用户，一般为手机号或电子邮箱
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dofqz")
		public String dofqz(String userid, HttpServletRequest request)   {
			String keyall = "dofqz" +userid;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			};
	
				String url ="https://way.jd.com/huiyutech/label";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("userid",userid); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}
		
		
		/**
		 * 		蜜罐数据
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "domg")
		public String domg(String name,String idCard,String phone, HttpServletRequest request)  {
			String keyall = "domg" +name+idCard+phone;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			};
	
				String url ="https://way.jd.com/juxinli/henypot4JD";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("name",name); //访问参数
				queryMap.put("idCard",idCard); //访问参数
				queryMap.put("phone",phone); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			return result;
		}
		/**
		 * 		手机号机主二要素验证
		 * 
		 * @return
		 * @throws Exception 
		 */
		@ResponseBody
		@RequestMapping(params = "dosjeys")
		public String dosjeys(String name,String mobile, HttpServletRequest request)   {
			String keyall = "dosjeys" +name+mobile;
			String result =getfxbbres(keyall);
			if(!StringUtil.isEmpty(result)){
				return  result;
			};
	
				String url ="https://way.jd.com/huiyutech/MobileOwner";//请求接口地址
				 RequestModel model = new RequestModel() ;
				model.setGwUrl(url);
				model.setAppkey(jdwxkey);
				Map queryMap = new HashMap();
				queryMap.put("name",name); //访问参数
				queryMap.put("mobile",mobile); //访问参数
				model.setQueryParams(queryMap);
				WxApiCall call = new WxApiCall();
				call.setModel(model);
				result = call.request();
				System.out.print(result);
			setfxbbres(keyall,result);

			return result;
		}



	/**
	 * 		逾期记录
	 *
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "dosyqjl")
	public String dosyqjl(String name,String idCard,String mobile, HttpServletRequest request)  {

		String keyall = "dosyqjl" +name+idCard;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		};
		String url ="https://way.jd.com/hangzhoushumaikeji/overdue_check";//请求接口地址
		RequestModel model = new RequestModel() ;
		model.setGwUrl(url);
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		String Strbodystr = "name="+name+"&idcard="+idCard+"&mobile="+mobile;
		model.setBodyStr(Strbodystr);
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		result = call.request();
		System.out.print(result);
		setfxbbres(keyall,result);

		return result;

	}

	/**
	 * 		置信反欺诈报告
	 *
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "dozxfqz")
	public String dozxfqz(String name,String idCard,String mobile, HttpServletRequest request)   {

        String okflag = "N";
		String 	appKey = null;
		String 	appSecret = null;


		RequestModel modelget = new RequestModel();
		modelget.setGwUrl("https://way.jd.com/powerlaunch/getAppInfoLoan");
		modelget.setAppkey(jdwxkey);
		Map queryMapget = new HashMap();
		queryMapget.put("account",ResourceUtil.getConfigByName("zxuser")); //访问参数
		queryMapget.put("password",ResourceUtil.getConfigByName("zxpassword")); //访问参数
		modelget.setQueryParams(queryMapget);
		WxApiCall callget = new WxApiCall();
		callget.setModel(modelget);
		String resultget = callget.request();
		try {
			JSONObject res = JSONObject.fromObject(resultget);
			if(res.get("code").equals("10000")){
				JSONObject reszl = res.getJSONObject("result").getJSONObject("result");//最终信息
			 	appKey = reszl.get("appKey").toString();
			 	appSecret = reszl.get("appSecret").toString();
			};
		}catch (Exception e){

		}
		if(!StringUtil.isEmpty(appKey)&&!StringUtil.isEmpty(appSecret)){
			okflag="Y";
		}
		String result =null;
		if(okflag.equals("Y")){
			String url ="https://way.jd.com/powerlaunch/riskInfo";//请求接口地址
			RequestModel model = new RequestModel() ;
			model.setGwUrl(url);
			model.setAppkey(jdwxkey);
			Map queryMap = new HashMap();
			queryMap.put("appKey",appKey); //访问参数
			queryMap.put("appSecret",appSecret); //访问参数
			queryMap.put("name",name); //访问参数
			queryMap.put("idCard",idCard); //访问参数
			queryMap.put("mobile",mobile); //访问参数
			model.setQueryParams(queryMap);
			WxApiCall call = new WxApiCall();
			call.setModel(model);
			result = call.request();
			System.out.print(result);
		}
		return result;

	}


	/**
	 * 		VIN车架号详细信息查询
	 *
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "dovindetail")
	public String dovindetail(String frameno,HttpServletRequest request)   {
		String keyall = "dovindetail" +frameno;
		String result =getfxbbres(keyall);
		if(!StringUtil.isEmpty(result)){
			return  result;
		};

		String url ="https://way.jd.com/getLimit/getVINDetail";//请求接口地址
		RequestModel model = new RequestModel() ;
		model.setGwUrl(url);
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("VIN",frameno); //访问参数
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		result = call.request();
		System.out.print(result);
		setfxbbres(keyall,result);

		return result;
	}




//	model.setGwUrl("https://way.jd.com/getLimit/getVINDetail");
	/**
	 * 		车辆违章城市
	 *
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "doclwzcs")
	public String doclwzcs(HttpServletRequest request)   {
		String result =null;

		String url ="https://way.jd.com/jisuapi/carorg";//请求接口地址
		RequestModel model = new RequestModel() ;
		model.setGwUrl(url);
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("onlysupport","1"); //访问参数
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		result = call.request();
		System.out.print(result);
		return result;
	}

	/**
	 * 		车辆违章
	 *
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(params = "doclwz")
	public String doclwz(String createby,String carorg,String lsprefix,String lsnum,String frameno,String engineno,String by2,String by1, HttpServletRequest request)  {
		String result =null;
		String url ="https://way.jd.com/jisuapi/query9";//请求接口地址
		RequestModel model = new RequestModel() ;
		model.setGwUrl(url);
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("carorg",carorg); //访问参数
		queryMap.put("lsprefix",lsprefix); //访问参数
		queryMap.put("lsnum",lsnum); //访问参数
		queryMap.put("lstype","02"); //02：小型汽车号牌，01：大型汽车号牌，03：使馆汽车号牌，04：领馆汽车号牌，05：境外汽车号牌，06：外籍汽车号牌，07：两、三轮摩托车号牌，08：轻便摩托车号牌，09：使馆摩托车号牌，10：领馆摩托车号牌，11：境外摩托车号牌，12：外籍摩托车号牌，13：农用运输车号牌
		queryMap.put("frameno",frameno); //车架号
		queryMap.put("engineno",engineno); //发动机号
		queryMap.put("iscity","1"); //是否返回城市 1返回 默认0不返回 不一定100%返回结果，准确度90% town、lat、lng仅供参考

//		queryMap.put("carorg","shandong"); //访问参数
//		queryMap.put("lsprefix","鲁"); //访问参数
//		queryMap.put("lsnum","A12345"); //访问参数
//		queryMap.put("lstype","02"); //02：小型汽车号牌，01：大型汽车号牌，03：使馆汽车号牌，04：领馆汽车号牌，05：境外汽车号牌，06：外籍汽车号牌，07：两、三轮摩托车号牌，08：轻便摩托车号牌，09：使馆摩托车号牌，10：领馆摩托车号牌，11：境外摩托车号牌，12：外籍摩托车号牌，13：农用运输车号牌
//		queryMap.put("frameno","123456"); //车架号
//		queryMap.put("engineno","123456"); //发动机号
//		queryMap.put("iscity","1"); //是否返回城市 1返回 默认0不返回 不一定100%返回结果，准确度90% town、lat、lng仅供参考

		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		result = call.request();
//		result = "{\"code\":\"10000\",\"charge\":false,\"msg\":\"查询成功\",\"result\":{\"status\":\"0\",\"msg\":\"\",\"result\":{\"lsprefix\":\"闽\",\"lsnum\":\"A67X90\",\"carorg\":\"fuzhou\",\"usercarid\":\"43131943\",\"count\":\"1\",\"totalprice\":\"150\",\"totalscore\":\"3\",\"list\":[{\"time\":\"2018-03-11 18:28:30\",\"address\":\"福州机场高架桥上\",\"content\":\"机动车违反禁令标志指示的\",\"legalnum\":\"1344\",\"price\":\"150\",\"score\":\"3\",\"handlefee\":\"\",\"agency\":\"\",\"illegalid\":\"17964636\",\"province\":\"\",\"city\":\"\",\"town\":\"\",\"lat\":\"0.0000000000\",\"lng\":\"0.0000000000\",\"canhandle\":\"0\"}]}}}";
		System.out.print(result);
		systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
		fxjClwz fxjClwz = JSONHelper.fromJsonToObject(result,fxjClwz.class);
		return result;
	}




	@ResponseBody
	@RequestMapping(params = "do360wz")
	public String do360wz(String createby,String lsnum,String frameno,String engineno,HttpServletRequest request) throws Exception {
		String result =null;
		RequestModel model = new RequestModel();
		model.setGwUrl("https://way.jd.com/jnstkj/violation_query");
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("cph",lsnum); //访问参数
		queryMap.put("cx","02"); //访问参数
		queryMap.put("cjh",frameno); //访问参数
		queryMap.put("fdj",engineno); //访问参数
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		call.request();
		result = call.request();
		return result;
	}


	@ResponseBody
	@RequestMapping(params = "doclnj")
	public String doclnj(String createby,String lsnum,String frameno,String engineno,HttpServletRequest request) throws Exception {
		String result =null;
		RequestModel model = new RequestModel();
		model.setGwUrl("https://way.jd.com/utimes/annualInspection");
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("license_number",lsnum); //访问参数
		queryMap.put("vehicle_type","小型汽车"); //访问参数
		queryMap.put("cjh",frameno); //访问参数
		queryMap.put("fdj",engineno); //访问参数
		queryMap.put("hdzk","5"); //访问参数
		queryMap.put("syxz","A"); //访问参数
		queryMap.put("ccdjrq","2017-12-05"); //访问参数
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		call.request();
		result = call.request();
		return result;
	}


	@ResponseBody
	@RequestMapping(params = "dosms")
	public String dosms(String mobile,String content, HttpServletRequest request) throws Exception {
		String result =null;
		RequestModel model = new RequestModel();
		model.setGwUrl("https://way.jd.com/chuangxin/dxjk");
		model.setAppkey(jdwxkey);
		Map queryMap = new HashMap();
		queryMap.put("mobile",mobile); //访问参数
		queryMap.put("content",new String(content.getBytes(),"UTF-8") ); //访问参数
		model.setQueryParams(queryMap);
		WxApiCall call = new WxApiCall();
		call.setModel(model);
		call.request();
		result = call.request();
		System.out.print(result);
		return result;
	}


		
	/**
	 * 身份证识别
	 * imgfile 文件路径
	 * @return
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(params = "dosfzshibie")
	public String doshenfenzheng(String imgfile,String shibietype, HttpServletRequest request) throws Exception {
		String message = null;
		String result =null;
		String jushib=null;
		AjaxJson j = new AjaxJson();
        String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
			//得到图片base64编码
			String base64Str = Base64Utils.GetImageStr(imgfile);
			String url ="http://apis.juhe.cn/idimage/verify";//请求接口地址
			Map params = new HashMap();//请求参数
			params.put("key",sfzappkey);//应用APPKEY(应用详细页查询)
			params.put("dtype","");//返回数据的格式,xml或json，默认json
			if(shibietype.equals("2")){
				shibietype = "front";
			}else{
				shibietype = "back";
			}
			params.put("side",shibietype);//固定值：  front:正面识别;back:反面识别;
			params.put("image",base64Str);//固定值：
			result =HttpRequest.juhenet(url, params, "POST");
			//systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
			System.out.print(result);
		return result;
	}
	
	
	/**
	 * 人脸对比
	 * imgfile 文件路径
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(params = "dorenlianduibi")
	@ResponseBody 
	public String dorenlianduibi(String imgfile,String realname, String idcard,HttpServletRequest request) throws Exception {
		String message = null;
		String result =null;
		AjaxJson j = new AjaxJson();
		String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
			//得到图片base64编码
			String base64Str = Base64Utils.GetImageStr(imgfile);
			String url ="http://apis.juhe.cn/verifyface/verify";//请求接口地址
			Map params = new HashMap();//请求参数
			params.put("key",rldbappkey);//应用APPKEY(应用详细页查询)
			params.put("dtype","");//返回数据的格式,xml或json，默认json
			params.put("realname",realname);//固定值：
			params.put("idcard",idcard);//固定值：
			params.put("image",base64Str);//固定值：
			result =HttpRequest.juhenet(url, params, "POST");
			j.setObj(result);
			//systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
			System.out.print(result);
			j.setMsg(message);
			return result;
	}
	
	/**
	 *行驶证识别
	 * imgfile 文件路径
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(params = "doxszshibie")
	@ResponseBody
	public String doxszshibie(String imgfile,String cardType,HttpServletRequest request) throws Exception {
		String message = null;
		String result =null;
		AjaxJson j = new AjaxJson();
		String ctxPath= ResourceUtil.getConfigByName("webUploadpath");//demo中设置为D://upFiles,实际项目应因事制宜
		//String path=request.getParameter("imgfile");
		String imgpath=ctxPath+File.separator+imgfile;
		File fileDelete = new File(imgpath);
		if (!fileDelete.exists() || !fileDelete.isFile()) {
			j.setSuccess(true);//不存在前台也给他删除
		}
		else{
			
			CloseableHttpClient httpclient = HttpClients.createDefault();
			CloseableHttpResponse response;
            RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
            HttpPost httppost = new HttpPost("http://v.juhe.cn/certificates/query.php");
            String key = zjsbappkey;
			// StringBody封装String类型的参数
            StringBody keyBody = new StringBody(key, ContentType.TEXT_PLAIN);
            StringBody typeBody = new StringBody(cardType, ContentType.TEXT_PLAIN);
            

			 FileBody bin = new FileBody(fileDelete);
			 HttpEntity reqEntity = MultipartEntityBuilder.create()
	                    .addPart("pic", bin).addPart("key", keyBody)
	                    .addPart("cardType", typeBody).build();
	            httppost.setEntity(reqEntity);
	            httppost.setConfig(config);
	            // 执行网络请求并返回结果
	             response = httpclient.execute(httppost);
	            HttpEntity resEntity = response.getEntity();
	            if (resEntity != null) {
	                result = ConvertStreamToString(resEntity.getContent(), "UTF-8");
	            }
			//result="{'reason':'操作成功','result':{'保留':'','号牌号码':'川AA780D','车辆类型':'小型轿车','所有人':'叶魁友','住址':'成都市龙泉驿区山泉镇联台村7组5号','品牌型号':'北京现代牌BH7164MX','车辆识别代号':'LBEHDAEB58Y038860','发动机号码':'8B213508','注册日期':'2008-07-08','发证日期':'2015-06-04','使用性质':'非营运'},'error_code':0}";
			j.setObj(result);
			System.out.print(result);
		}

		j.setMsg(message);
		return result;
	}

	@ResponseBody
	@RequestMapping(params = "dozcx")
	public String dozcx(String account_name,String id_number,String account_mobile,  HttpServletRequest request) throws Exception {
		String res = null;
		String zcxurl = ResourceUtil.getConfigByName("zcx.url");
		String zcxaccount = ResourceUtil.getConfigByName("zcx.account");
		String zcxcid = ResourceUtil.getConfigByName("zcx.cid");
		LinkedHashMap<String, Object> paramMap = new LinkedHashMap<String, Object>();
		paramMap.put("account",zcxaccount);
		paramMap.put("cid",id_number);
        paramMap.put("mobile",account_mobile);
        paramMap.put("name",account_name);
		paramMap.put("reqTid",id_number);
		String sign = createSign(paramMap);
		paramMap.put("sign",sign);
		System.out.print("url********************==="+zcxurl);
		try {
			res = HttpUtil.get(zcxurl, paramMap);
		}catch (Exception e){
		}
		System.out.print("*****************res******"+res);
		return  res;
	}

	public static String createSign(LinkedHashMap<String, Object> params) {
        Set<String> keysSet = params.keySet();
        Object[] keys = keysSet.toArray();

		Iterator it = params.entrySet().iterator();
		        Arrays.sort(keys);
		StringBuffer temp = new StringBuffer();
		boolean first = true;
		while (it.hasNext()) {
			Map.Entry entry = (Map.Entry) it.next();
			temp.append(entry.getKey());
			Object value = entry.getValue();
			String valueString = "";
			if (null != value) {
				valueString = String.valueOf(value);
				temp.append(valueString.toString());
			}
		}
		temp.append(ResourceUtil.getConfigByName("zcx.cid"));
        System.out.print("temp*****************res******"+temp.toString());
		String result =  MD5(temp.toString()).toUpperCase();
        System.out.print("result***********************"+result);

        return result;
    }
    private static String MD5(String s) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bytes = md.digest(s.getBytes("utf-8"));
            return toHex(bytes);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


    // 此方法是把传进的字节流转化为相应的字符串并返回，此方法一般在网络请求中用到
    public static String ConvertStreamToString(InputStream is, String charset)
            throws Exception {
        StringBuilder sb = new StringBuilder();
        try (InputStreamReader inputStreamReader = new InputStreamReader(is,charset)) {
            try (BufferedReader reader = new BufferedReader(inputStreamReader)) {
                String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line).append("\r\n");
                }
            }
        }
        return sb.toString();
    }
}
